import assert from 'assert';
import Router from 'koa-router';
import tokenAuth from '../middleware/tokenAuth';
import componentContainer from '../../components/componentContainer';

const router = new Router({
  prefix: '/api/suggestion',
});

router.use(tokenAuth());

router.post('/', async (ctx) => {
  const apiBridge = componentContainer.getApiBridge();
  const { message } = ctx.request.body;
  assert(message, 'message should exist');

  ctx.body = await apiBridge.getMessageSuggestion(message);
});


export default router;
